#!/usr/bin/env python3
"""
visualize_tree.py
Visualize process tree from a single session (load pickled session).
"""
import pickle
import networkx as nx
import matplotlib.pyplot as plt
import sys

path = sys.argv[1]
with open(path, 'rb') as f:
    sessions = pickle.load(f)

s = sessions[0]
from graph_utils import build_process_tree
G = build_process_tree(s['events'])
plt.figure(figsize=(10,10))
pos = nx.spring_layout(G)
nx.draw(G, pos, with_labels=False, node_size=30)
plt.show()